<{include file="OA/cooperation/header.tpl"}>
	<section id="spread_one" class="column">
		
        <{if $alert_message}>
		<h4 class="alert_info"><{$alert_message}></h4>
        <{/if}>
		

		<article class="module width_3_quarter">
		<header>
			<h3 class="tabs_involved ">修改合作包信息</h3>
		</header>
		<form action='../update_submit' method='post' id="add_apk">
		<div class="tab_container">
			<div id="tab1" class="tab_content">
			<table class="tablesorter apk-edit" cellspacing="0"> 
			<tbody> 
				<tr> 
   					<td><label class="l01">合作包包名</label><input type="text" class="package_name" name="packagename" value="<{$apk.packagename}>" size="24"> 
					<input type="hidden" name="id" value="<{$apk.id}>">
					</td> 
					<td>
						<span class="package_icon_url" ><img src="<{$apk.icon_url}>"></span>
						<span class="apk_name" ><{$apk.name}></span>
						<input type="hidden" name="apk_name" class="input_apk_name" value="<{$apk.name}>">
					</td> 
				</tr> 
				<tr> 
					<td>
                       <label class="l01">支付方式</label>
                        <select name='pay_type'>
                            <{foreach from="$pay_type" item=v}>
                                 <option value ="<{$v.id}>"><{$v.name}></option>
                            <{/foreach}>
                        </select>
                    </td>
					<td>
                        <label class="l01">合作公司</label>
						<select name='corporation' id="corpor">
							<{foreach from="$devs" item=v}>
 								 <option value ="<{$v.id}>" <{if $v.id == $apk.corporation}> selected <{/if}>><{$v.name}></option>
							<{/foreach}>
						</select>
                    </td>
				</tr> 
				 <tr>
					<td>
                        <label class="l01">cp分成比例</label><input type="text" class="ratio" name="ratio" size="4" value="<{$apk.ratio}>">%
                    </td>
                    <td>
                        <label class="l01">税费比例</label><input type="text" name="cost_ratio" size="4" value="<{$apk.cost_ratio}>">%
                    </td>
                </tr>
				 <tr>
					<td>
                        <label class="l01">结算联系人</label>
                        <select name="payment_uid" class="payment_contacts">
                            <{foreach from="$payments" item=v}>
                                 <option value ="<{$v.id}>" <{if $v.id == $apk.payment_uid}> selected <{/if}>><{$v.name}></option>
                            <{/foreach}>
                        </select>
                    </td>
					<td>
                        <label class="l01">商务联系人</label>
                        <select name="business_uid" class="buisness_contacts">
                            <{foreach from="$business" item=v}>
                                 <option value ="<{$v.id}>" <{if $v.id == $apk.business_uid}> selected <{/if}>><{$v.name}></option>
                            <{/foreach}>
                        </select>
                        </select>
                    </td>
                </tr>
				<tr>
                    <td>
                        <label class="l01">合作开始时间</label><input type="text" value="<{$apk.start_time}>" id="date1" name='start_time' />
                    </td>
                    <td>
                        <label class="l01">合作结束时间</label><input type="text" value="<{$apk.end_time}>" id="date1" name='end_time' />
                    </td> 
				</tr> 
				<tr>
					<td colspan="2" style="text-align:center">
						<input type="submit" class="bulid_action fw spread_submit" value="修改">
					</td>
				</tr>
			</tbody> 
			</table>
			</div><!-- end of #tab1 -->
		</div><!-- end of .tab_container -->
		</form>	
		</article><!-- end of content manager article -->
		<div class="clear"></div>
	</section>
	<script>
		$('#add_apk').submit(function() {
			// form validation.
			if ($('.ratio').val() == '') {
				alert('分成比例不能为空');
				return false;
			}
			return confirm('是否确定修改此合作包？');
		});
		$('.package_name').blur(function () {
			var package_name  = $('.package_name').val();	
            $.get('../apk_info?package_name=' + package_name, {} ,function (data) {
					if(data.name){
						$('.package_icon_url').html('<img src="'+data.iconUrl+'">');
						$('.input_apk_name').val(data.name);
					}else{
						alert('哇吖中没有找到此款应用！');
					}
            } , 'json');
		});
		$('#corpor').change(function () {
            var corp_id  = $('#corpor').val();
            var url = '../../developer/get_contacts/'+ corp_id ;
            $.get(url, {} ,function (data) {
                    if(data){
                        var html = ''
                        for (var i = 0; i < data.length; ++i)
                        {
                         var id = data[i].id;
                         var name = data[i].name;

                         html += '<option value='+ id +'>'+ name +'</option>';
                        }
                        $('.buisness_contacts').html(html);
                        $('.payment_contacts').html(html);
                    }else {
                        $('.buisness_contacts').html('');
                        $('.payment_contacts').html('');
                    }
            } , 'json');
        });
	</script>
<{include file="OA/cooperation/footer.tpl"}>
